<?php
/**
 * 功能描述：公共部分
 */

class Admin_CommModel extends Model {

    /**
     * Notes:添加数据
     */
    function addData($mould, $data){
        $sql['data'] = $data;
        $sql['table'] = $mould;
        $db = $this->conn('mysql1');
        $db->add($sql);
        $return  = $db->rowCount();
        if($return){
            return $db->returnId();
        }
        return 0;
    }

    /**
     * Notes:示例->获取国家
     * Desc:链接mysql1，链接方式mysqli
     */
    function getcountryLists($limit){
        $sql['field'] = 'Code,Name';
        $sql['table'] = 'country';
        $sql['limit'] = $limit;
        $db = Model::conn('mysql1');
        return $db->select($sql,true);
    }

    /**
     * Notes:示例->获取城市
     * Desc:链接mysql2，链接方式pdo
     */
    function getCityLists($id){
        $sql = "select ID,Name from city where id<:id";
        $db = $this->conn('mysql2');
        $stmt = $db->prepare($sql);
        $stmt->bindValue('id', $id);
        $stmt->execute();
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    /**
     * Notes:示例->获取用户
     * Desc:链接oracle，链接方式pdo
     */
    function getUserInfo($uCode){
        $sql = "select ucode,uname from sys_user where ucode=:uCode";
        $db = $this->conn('oracle');
        $stmt = $db->prepare($sql);
        $stmt->bindValue('uCode', $uCode);
        $stmt->execute();
        return $stmt->fetch();
    }

}